class Publication < ActiveRecord::Base
  paginates_per 10

  has_one :document, :as => :source, :dependent => :destroy
  has_and_belongs_to_many :authors

  default_scope order('created_at DESC')

  after_initialize lambda { |p| p.build_document }, :unless => :document

  accepts_nested_attributes_for :document
  #accepts_nested_attributes_for :authors

  validates_presence_of :document
end
